import java.io.File;
import java.io.IOException;
import java.util.Vector;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

public class ExportNote {
	static Vector title;
	static Vector content, remindTime, ways, mail;
	
	public ExportNote() throws Exception{
		title = new Vector();
		content = new Vector();
		remindTime = new Vector();
		ways = new Vector();
		mail = new Vector();
		DatabaseCtrl.initCon2();
		title = DatabaseCtrl.getRemindTitle();
		content = DatabaseCtrl.getRemindContent();
		remindTime = DatabaseCtrl.getRemindTime();
		ways = DatabaseCtrl.getRemindWay();
		mail = DatabaseCtrl.getRemindMail();
		DatabaseCtrl.close2();
		
	}

    public static void main(String[] args)
            throws IOException, RowsExceededException, WriteException {
        //1:����excel�ļ�
        File file=new File("remindData.xls");
        file.createNewFile();
        

        //2:����������
        WritableWorkbook workbook=Workbook.createWorkbook(file);
        //3:����sheet,���õڶ�����..��sheet���������Ƽ���
        WritableSheet sheet=workbook.createSheet("��������", 0);
        //4������titles
        String[] titles={"noteTitle","content","reminderTime", "ways(1.����,2.�ʼ�)", "mail"};
        //5:��Ԫ��
        Label label=null;
        //6:����һ����������
        for(int i=0;i<titles.length;i++){
            //x,y,��һ�е�����
            label=new Label(i,0,titles[i]);
            //7����ӵ�Ԫ��
            sheet.addCell(label);
        }
         
        //8��ģ�����ݿ⵼������
        for(int i=0;i<title.size();i++){
            //��ӱ��⣬��i�е�һ��
            label=new Label(0,i+1,title.get(i)+"");
            sheet.addCell(label);

            //�������
            label=new Label(1,i+1,content.get(i)+"");
            sheet.addCell(label);

            //���ʱ��
            label=new Label(2,i+1,remindTime.get(i)+"");
            sheet.addCell(label);
            
            //��ӷ�ʽ
            label=new Label(3,i+1,ways.get(i)+"");
            sheet.addCell(label);
            
            //����ʼ�
            label=new Label(4,i+1,mail.get(i)+"");
            sheet.addCell(label);
        }

        
        //д�����ݣ�һ���ǵ�д�����ݣ���Ȼ�㶼��ʼ���������ˣ�excel����ɶ��û��
        workbook.write();
        //���һ�����رչ�����
        workbook.close();
        System.out.println("������ɣ�");
		try {
			Runtime.getRuntime().exec("cmd  /c  start  E:\\project\\java\\test\\remindData.xls");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
}